<template>
<slot :controller="controller" :store="store" :model="model" :classNames="classNames">
  <AppExpBar 
    :class="classNames">
    <template #titleBar>
      <slot name="Caption" :controller="controller" :store="store" :model="model">
      <div class="control-header__left__caption">
        <span class="text">{{model.lanResTag ? $t(model.lanResTag, model.title) : model.title}}</span>
      </div>
      </slot>
    </template>
    <template #quickGroup>
      <slot name="quickGroup"></slot>
    </template>
    <template #quickSearch>
        <slot name="ViewQuickSearch" :controller="controller" :store="store" :model="model" :actions="{ handleQuickSearch }">
        <AppQuickSearch @search="(searchValue:string) => handleQuickSearch(controller, searchValue)" :placeholder="model.quickSearchPlaceholder"/>
        </slot>
    </template>
    <template #toolbar>
      <slot name="ViewToolbar" :controller="controller" :store="store" :model="model" :actions="{ handleToolbarItemClick }">
          <AppToolbar
              name="toolbar"
              mode="DEFAULT"
              :items="store.toolbarItems"
              :loading="store.loadingHelper.isLoading"
              @item-click="(name: string, event: MouseEvent, logic: any) => { handleToolbarItemClick(controller, name, event, logic) }">
          </AppToolbar>
      </slot>
    </template>
    <template #default>
      <slot name="IBIZOrderListExpList" :controller="controller" :store="store" :model="model" :actions="{ handleCtrlInit, handleCtrlAction, handleCtrlDestroy }">
      <IBIZOrderListExpList
          :selectFirstDefault='true'
            :singleSelect='true'
          :actions="{
              loadDraftAction: 'GetDraft',
              createAction: 'Create',
              fetchAction: 'FetchDefault',
              removeAction: 'Remove',
              updateAction: 'Update'
          }"
          :openView="store.openView"
          :newView="store.newView"
          name="listexpbar_list"
          v-bind="model.ctrlParams.IBIZOrderlistexpbar_list"
          :context="store.context"
          :viewParams="store.viewParams"
          :closeView="store.closeView"
          :pLoadingHelper="store.loadingHelper"
          :pViewCtx="store.viewCtx"
          @ctrl-init="(name:string, ability:any) => { handleCtrlInit(controller, name, ability) }"
          @ctrl-action="(name:string, action:any, data:any) => { handleCtrlAction(controller, name, action, data) }"
          @ctrl-destroy="(name:string, data:any) => { handleCtrlDestroy(controller, name, data) }"></IBIZOrderListExpList>
      </slot>
    </template>
  </AppExpBar>
</slot>
</template>
<script setup lang="ts">
// 基于template/src/widgets/{{appEntities}}/{{ctrls@LISTEXPBAR}}-list-exp-bar/{{spinalCase ctrl.codeName}}-list-exp-bar-base.vue.hbs生成
import { AppExpBar } from '@components/widgets/exp-bar';
import IBIZOrderListExpList from '@widgets/ibiz-order/list-exp-list/list-exp-list.vue';
import { AppToolbar } from '@components/widgets/toolbar';
import { useProps, useBasic, useAction, useController } from './list-exp-view-layoutlistexpbar-list-exp-bar-hook';
import { ListExpBarActionType, IListExpBarAbility, IListExpBarStore, IParam } from "@/core";

// 输入参数
const props = defineProps(useProps());

// 基础数据
const { 
    model,
    controlID, 
    getClassNames, 
    useNavParamsBind, 
    useEventBind, 
    handleCtrlDestroy,
    handleCtrlInit, 
    handleCtrlAction,
    handleToolbarItemClick,
    handleQuickSearch
} = useBasic(props);

const emit = defineEmits<{
    (event: 'ctrl-action', name: string, action: ListExpBarActionType, data: IParam[]): void;
    (event: 'ctrl-init', name: string, data: IListExpBarAbility): void;
    (event: 'ctrl-destroy', name: string, data: IParam): void;
}>();

const evt = useEventBind(emit);
const classNames = computed(() => {
  return getClassNames(props);
});

const controller = useController(props, evt, { controlID });

useNavParamsBind(controller, props);

const store: IListExpBarStore = controller.getStore();

onMounted(() => {
    controller.ctrlMounted();
});

onUnmounted(() => {
    controller.ctrlDestroy();
})
</script>